/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    division: { type: 'string', _type: 'string', title: '销售公司', enableArea: [ 'table','input', 'detail', ], },
    _code: {
      type: 'string',
      _type: 'string',
      required: true,
      title: '租用记录编码',
      enableArea: [ 'input', 'detail', ],
    },
    name: {
      type: 'string',
      _type: 'string',
      required: true,
      title: '物料名称',
      enableArea: [ 'table', 'input', 'detail', ],
    },
    subcategory: {
      type: 'string',
      _type: 'string',
      title: '物料小类',
      enableArea: [ 'table', 'input', 'detail', ],
    },
    spec: { type: 'string', _type: 'string', title: '规格', enableArea: [ 'table', 'input', 'detail', ], },
    type: { type: 'string', _type: 'string', title: '类别', enableArea: [ 'table', 'input', 'detail', ], },
    number: { type: 'string', _type: 'string', title: '型号', enableArea: [ 'table', 'input', 'detail', ], },
    customer: { type: 'string', _type: 'string', title: '客户', enableArea: [ 'table', 'input', 'detail', ], },
    customerCode: { type: 'string', _type: 'string', title: '客户编码', enableArea: [ 'input', 'detail', ], },

    count: { type: Number, _type: 'number', title: '客户编码', enableArea: [ 'input', 'detail', ], },
    tax: { type: Number, _type: 'number', title: '税率', enableArea: [ 'input', 'detail', ], },
    price: { type: Number, _type: 'number', title: '单价', enableArea: [ 'input', 'detail', ], },
    startDate: { type: Date, _type: 'date', title: '开始时间', enableArea: [ 'table', 'input', 'detail', ], },
    endDate: { type: Date, _type: 'date', title: '结束时间', enableArea: [ 'table', 'input', 'detail', ], },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('Rent', _schema);
};
